/**
 * @(#)Ruso.java
 *
 *
 * @author
 * @version 1.00 2011/11/25
 */
import javax.swing.JProgressBar;
import java.util.StringTokenizer;

public class Ruso{
	private static String original;
	private static String traduccion;

    public static String formatear(String original, String idioma, String traduccion, JProgressBar avance){
    	String r="";

    	r+="<center>\n";
    	r+="\t<table class=\"ruso\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
    	r+="\t\t<tr class=\"encabezado\">\n";
    	r+="\t\t\t<td align=\"center\" width=\"50%\">Ruso</td>\n";
    	r+="\t\t\t<td align=\"center\" width=\"50%\">"+idioma+"</td>\n";
    	r+="\t\t</tr>\n";

    	StringTokenizer lOriginal=new StringTokenizer(original, "\n", true);
    	StringTokenizer lTraduccion=new StringTokenizer(traduccion, "\n");

    	boolean anterior=false;
    	int total=lOriginal.countTokens();
    	avance.setMaximum(total);

    	for(int k=0, contador=0; lOriginal.hasMoreTokens(); k++){
    		String cOriginal=lOriginal.nextToken();

    		if(cOriginal.equals("\n")){
    			if(anterior){
    				r+="\t</table>\n";
    				r+="\t<br>\n";
			    	r+="\t<table class=\"ruso\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
    			}else{
    				anterior=true;
	    			continue;
    			}
    		}else{
	    		String cTraduccion=(lTraduccion.hasMoreTokens())?lTraduccion.nextToken():"";

	    		r+="\t\t<tr id=\"linea_"+contador+"\" onmouseover=\"enfocarLinea(this)\" onmouseout=\"desenfocarLinea(this)\" onclick=\"posicionarVideo("+contador+")\">\n";
	    		r+="\t\t\t<td align=\"center\" width=\"50%\">"+cOriginal+"</td>\n";
	    		r+="\t\t\t<td align=\"center\" width=\"50%\">"+cTraduccion+"</td>\n";
	    		r+="\t\t</tr>\n";

	    		avance.setValue(k);
	    		contador++;
	    		anterior=false;
    		}
    	}
    	avance.setValue(total);

    	r+="\t</table>\n";
    	r+="</center>\n";

    	return r;
    }
}